﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouShuShenQi.BlazorCore.Models;
using TouShuShenQi.BlazorCore.Repositorys;

namespace TouShuShenQi.BlazorCore.Services
{
    /// <summary>
    /// 书籍服务
    /// </summary>
    public class BookService
    {
 
        private readonly HttpClient _httpClient;
        private readonly BaseRepository<BookModel> _bookRep;
        private readonly BaseRepository<BookChapterModel> _bookChapterRep;

 

        public BookService(HttpClient httpClient, BaseRepository<BookModel> bookRep, BaseRepository<BookChapterModel> bookChapterRep)
        {
            _httpClient = httpClient;
            _bookRep = bookRep;
            _bookChapterRep = bookChapterRep;
        }

        /// <summary>
        /// 插入
        /// </summary>
        /// <returns></returns>
        public async Task<BookModel> InsertAsync(int i)
        {
            var BookItem = new BookModel
            {
                Name = $"测试数据{i}",
                Author = "痞子再",
                Summary = "摘要",
                Description = "描述",
                TotalWords = new Random().Next(100),
                Views = new Random().Next(100),
                CreatedTime = DateTime.Now
            };
            BookItem.Id =  await _bookRep.InsertAsync(BookItem);
            return BookItem;
        }


    }
}
